## [1] "/Users/peizhi/Documents/GitHub/Peizhi_Zhang/hw02"
Provide a leaflet map of the highest severity fires (i.e. subset to the highest category in HIGHEST_LEVEL_DESC) contained in the file buiding_fires.csv. Ignore locations that fall outside the five boroughs of New York City. Provide at least three pieces of information on the incident in a popup.
Subset nyc_fires:
## cols(
## IM_INCIDENT_KEY = col_double(),
## FIRE_BOX = col_character(),
## INCIDENT_TYPE_DESC = col_character(),
## INCIDENT_DATE_TIME = col_character(),
## ARRIVAL_DATE_TIME = col_character(),
## UNITS_ONSCENE = col_double(),
## LAST_UNIT_CLEARED_DATE_TIME = col_character(),
## HIGHEST_LEVEL_DESC = col_character(),
## TOTAL_INCIDENT_DURATION = col_double(),
## ACTION_TAKEN1_DESC = col_character(),
## ACTION_TAKEN2_DESC = col_character(),
## ACTION_TAKEN3_DESC = col_character(),
## PROPERTY_USE_DESC = col_character(),
## STREET_HIGHWAY = col_character(),
## ZIP_CODE = col_double(),
## BOROUGH_DESC = col_character(),
## FLOOR = col_character(),
## CO_DETECTOR_PRESENT_DESC = col_character(),
## FIRE_ORIGIN_BELOW_GRADE_FLAG = col_double(),
## STORY_FIRE_ORIGIN_COUNT = col_double(),
## FIRE_SPREAD_DESC = col_character(),
## DETECTOR_PRESENCE_DESC = col_character(),
## AES_PRESENCE_DESC = col_character(),
## STANDPIPE_SYS_PRESENT_FLAG = col_double(),
## address = col_character(),
## lon = col_double(),
## lat = col_double()
## )
## # A tibble: 8,451 × 27
## IM_INCIDENT…¹ FIRE_…² INCID…³ INCID…⁴ ARRIV…⁵ UNITS…⁶ LAST_…⁷ HIGHE…⁸ TOTAL…⁹
## <dbl> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <dbl>
## 1 55672965 2595 111 - … 01/01/… 01/01/… 15 01/01/… 7 - Si… 11830
## 2 55673299 2591 111 - … 01/01/… 01/01/… 9 01/01/… 7 - Si… 18408
## 3 55674170 1726 111 - … 01/01/… 01/01/… 13 01/01/… 7 - Si… 5055
## 4 55675138 0966 111 - … 01/01/… 01/01/… 12 01/01/… 7 - Si… 6988
## 5 55675164 7343 111 - … 01/01/… 01/01/… 13 01/01/… 7 - Si… 9887
## 6 55675781 5034 111 - … 01/02/… 01/02/… 7 01/02/… 7 - Si… 2013
## 7 55676639 2124 111 - … 01/02/… 01/02/… 5 01/02/… 7 - Si… 6010
## 8 55677063 3701 111 - … 01/02/… 01/02/… 13 01/02/… 7 - Si… 6920
## 9 55677380 0948 111 - … 01/02/… 01/02/… 13 01/02/… 7 - Si… 8324
## 10 55677505 2371 111 - … 01/02/… 01/02/… 13 01/02/… 7 - Si… 6045
## # … with 8,441 more rows, 18 more variables: ACTION_TAKEN1_DESC <chr>,
## # ACTION_TAKEN2_DESC <chr>, ACTION_TAKEN3_DESC <chr>,
## # PROPERTY_USE_DESC <chr>, STREET_HIGHWAY <chr>, ZIP_CODE <dbl>,
## # BOROUGH_DESC <chr>, FLOOR <chr>, CO_DETECTOR_PRESENT_DESC <chr>,
## # FIRE_ORIGIN_BELOW_GRADE_FLAG <dbl>, STORY_FIRE_ORIGIN_COUNT <dbl>,
## # FIRE_SPREAD_DESC <chr>, DETECTOR_PRESENCE_DESC <chr>,
## # AES_PRESENCE_DESC <chr>, STANDPIPE_SYS_PRESENT_FLAG <dbl>, address <chr>, …
Leaflet map:
Start with the previous map. Now, distinguish the markers of the fire locations by PROPERTY_USE_DESC, i.e. what kind of property was affected. If there are too many categories, collapse some categories. Choose an appropriate coloring scheme to map the locations by type of affected property. Add a legend informing the user about the color scheme. Also make sure that the information about the type of affected property is now contained in the popup information. Show this map.
## [1] "/Users/peizhi/Documents/GitHub/Peizhi_Zhang/hw02"
Collapsing values in PROPERTY_USE_DESC:
Visualize by type of property:
Add marker clustering, so that zooming in will reveal the individual locations but the zoomed out map only shows the clusters. Show the map with clusters.
The second data file contains the locations of the 219 firehouses in New York City. Start with the non-clustered map (2b) and now adjust the size of the circle markers by severity (TOTAL_INCIDENT_DURATION or UNITS_ONSCENE seem plausible options). More severe incidents should have larger circles on the map. On the map, also add the locations of the fire houses. Add two layers (“Incidents”, “Firehouses”) that allow the user to select which information to show.
Note: For all time variables, the package lubridate has some nice convenience functions to get dates, times etc. into a preferred format.
## [1] "/Users/peizhi/Documents/GitHub/Peizhi_Zhang/hw02"
We now want to investigate whether the distance of the incident from the nearest firehouse varies across the city.
Show a choropleth map indicating how response times have developed over the years. What do you find?
## [1] "/Users/peizhi/Documents/GitHub/Peizhi_Zhang/hw02"
## OGR data source with driver: GeoJSON
## Source: "/Users/peizhi/Documents/nyc-zip-code-tabulation-areas-polygons.geojson", layer: "nyc-zip-code-tabulation-areas-polygons"
## with 262 features
## It has 11 fields
## OBJECTID postalCode PO_NAME STATE borough ST_FIPS CTY_FIPS
## 0 1 11372 Jackson Heights NY Queens 36 081
## 1 2 11004 Glen Oaks NY Queens 36 081
## BLDGpostalCode Shape_Leng Shape_Area
## 0 0 20624.69 20163284
## 1 0 23002.82 22606527
## X.id Group.1 x
## 0 http://nyc.pediacities.com/Resource/PostalCode/11372 11372 4
## 1 http://nyc.pediacities.com/Resource/PostalCode/11004 11004 4